import redis
'''
{"10.10.94.136", "6379"},
{"10.10.12.185", "6379"},
{"10.10.11.74", "6379"},
{"10.10.56.127", "6379"},
"user:lua:parentByToken:MxTARa2dBPmM5QtYb1mdLkoZ_xmE6rNau_v653LR9hPc0k7zbqmdHiYesG9kI0SFrVKeCuy15Qr2TbmynMhSe0xWA6le_uoaMOGCzWbEoU8=" "{\"userId\":11914593,\"parentId\":1147535,\"mobile\":\"1880000001\"}"
'''
#HostList=["10.10.94.136","10.10.12.185","10.10.11.74","10.10.56.127"]
HostList=["65.49.204.74","65.49.204.74"]
for Host in HostList:
    f = open('ParentInfo.txt', 'r')
    r = redis.Redis(host=Host, port=6379)
    while True:
        line=f.readline().strip()
        if len(line) == 0: #end of file
            break
        #print(line)
        userId,parentId,mobile,token=line.split(',')
        r.set("user:lua:parentByToken"+token,'"{\"userId\":'+userId+',\"parentId\":'+parentId+',\"mobile\":\"'+mobile+'\"}"')
        print(r.get("user:lua:parentByToken"+token))

    f.close()
